package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatMessageExchangecodeDto;
import com.usaas.search.service.IPlatMessageExchangecodeService;
/**
 * 平台推广信息—兑换码Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platMessageExchangecode")
public class AdminPlatMessageExchangecodeController extends BaseController {

    @Autowired
    private IPlatMessageExchangecodeService platMessageExchangecodeService;

    /**
     * 查询平台推广信息—兑换码列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:list')")
    @Log(title = "管理端平台推广信息—兑换码list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        List<PlatMessageExchangecodeDto> list = platMessageExchangecodeService.queryList(platMessageExchangecodeDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询平台推广信息—兑换码分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:list')")
    @Log(title = "管理端平台推广信息—兑换码page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        return platMessageExchangecodeService.queryPage(platMessageExchangecodeDto);
    }


    /**
     * 导出平台推广信息—兑换码列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:export')")
    @Log(title = "管理端导出平台推广信息—兑换码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        List<PlatMessageExchangecodeDto> list = platMessageExchangecodeService.queryList(platMessageExchangecodeDto);
        ExcelUtil<PlatMessageExchangecodeDto> util = new ExcelUtil<>(PlatMessageExchangecodeDto.class);
        util.exportExcel(response, list, "平台推广信息—兑换码数据");
    }

    /**
     * 获取平台推广信息—兑换码详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:query')")
    @Log(title = "管理端获取平台推广信息—兑换码详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        return AjaxResult.success(platMessageExchangecodeService.queryById(platMessageExchangecodeDto.getId()));
    }

    /**
     * 新增平台推广信息—兑换码
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:add')")
    @Log(title = "管理端新增平台推广信息—兑换码", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        return toAjax(platMessageExchangecodeService.add(platMessageExchangecodeDto));
    }

    /**
     * 修改平台推广信息—兑换码
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:edit')")
    @Log(title = "管理端修改平台推广信息—兑换码", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        return toAjax(platMessageExchangecodeService.update(platMessageExchangecodeDto));
    }

    /**
     * 删除平台推广信息—兑换码
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageExchangecode:remove')")
    @Log(title = "管理端删除平台推广信息—兑换码", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatMessageExchangecodeDto platMessageExchangecodeDto) {
        return toAjax(platMessageExchangecodeService.removeBatch(platMessageExchangecodeDto.getIds()));
    }

}
